import {
  discriCard
} from "../../utils/util.js";
import {
  switchInfo
} from "../../assets/js/sign.js"

Page({
  /**
   * 页面的初始数据
   */
  data: {
    list: [{
        icon: "/assets/img/u_gexx.png",
        title: "个人信息",
        path: "/pages/u_personalInformation/u_personalInformation"
      },
      {
        icon: "/assets/img/u_smrz.png",
        title: "实名认证",
        path: "/pages/u_realNameAuthentication/u_realNameAuthentication"
      },
      {
        icon: "/assets/img/u_fwhz.png",
        title: "服务患者",
        path: "/pages/u_servingPatients/u_servingPatients"
      },
      {
        icon: "/assets/img/u_fwdz.png",
        title: "服务地址",
        path: "/pages/u_serviceAddress/u_serviceAddress"
      },
      // {
      //   icon: "/assets/img/u_tsby.png",
      //   title: "投诉表扬",
      //   path: "/pages/inforMation/inforMation"
      // },
      // {
      //   icon: "/assets/img/u_yjfk.png",
      //   title: "意见反馈",
      //   path: "/pages/inforMation/inforMation"
      // },
      {
        icon: "/assets/img/u_gywm.png",
        title: "关于我们",
        path: "/pages/u_aboutus/u_aboutus"
      }
    ],
    userInfo: { //用户信息
      image: "/assets/img/userImg.png",
      name: "贾伟",
      age: "26",
      sex: "男",
      ageImage: "/assets/img/age.png",
      sexImage: "/assets/img/sex.png",
    }
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function(options) {},

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function() {
    this.setUserInfo()
  },
  // 切换身份信息
  onSwitchInfo() {
    switchInfo();
  },
  // 
  onTopath: function(e) {
    let item = e.currentTarget.dataset.item;
    wx.navigateTo({
      url: item.path
    })
  },
  // 设置用户信息
  setUserInfo: function() {
    // 可变信息
    let localuserInfo = wx.getStorageSync("userInfo");
    let userInfo = {
      image: "/assets/img/userImg.png",
      name: localuserInfo.userName || "未知",
      age: localuserInfo.age || "未知",
      sex: localuserInfo.sex == 1 ? "男" : "女" || "未知",
      ageImage: "/assets/img/age.png",
      sexImage: "/assets/img/sex.png",
    }
    this.setData({
      userInfo
    })
  }
})